GetVol
GetVol Obtain name and reference number of default volume only
short *vRefNum ; receives volume reference number GetVol returns the name and volume reference number of the current default volume or working directory.
volName is either the address of a 28-byte buffer or NIL (0). Upon return,
one of the following will be true:
address: The buffer at volName will contain the name of the root
directory of the default volume (as a length-prefixed
pascal-style string) and vRefNum will contain its volume reference number.
NIL (0) The word at vRefNum will contain the correct directory number of the current working directory.
Note: This does NOT return multiple-name pathnames.
vRefNum is the address of an unsigned short. Upon return it will contain the default volume's reference number (or if a previous call to SetVol used a working directory reference, vRefNum will receive that same value).
noErr (0) No error
nsvErr (-35) No such volume
Notes: Initially, the root of the startup disk is the default volume (or working
directory) for an application. After you set the default, you can use NIL for
a file name and 0 for a volume reference - this will imply the default
volume (or directory).
The lower-level PBGetVol returns the same information. Use
PBHGetVol to obtain a few snippets of additional data.
Use PBHSetVol to select both a default volume and directory. Use PBOpenWD to open a working directory and use SetVol to select the root of a volume (or a previously-opened working directory) as the default.
Example
#include <Files.h>
short vRef;
short rc;
rc = GetVol( volName, &vRef ); if ( rc ) { /* . . . process the error . . . */ }
PtoCstr( volName ); /* prepare for printf() */
printf( "Default volume - Reference number: %d; Name: '%s'\n",
vRef, volName );